package com.ymatou.iapi.livebuyer.testcase;

import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.AddDirtyWordsBean;
import com.ymatou.iapi.livebuyer.service.AddDirtyWordsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.utils.TestDataManager;
/**
*添加脏字列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AddDirtyWords{
	private static AddDirtyWordsBean adddirtywordsBean;
	private static AddDirtyWordsCall adddirtywordsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("添加脏字列表");
	}

	@Before
	public void caseUp() {
		adddirtywordsBean=new AddDirtyWordsBean();
		adddirtywordsCall=new AddDirtyWordsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(adddirtywordsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AddDirtyWords_001() {
		Logger.start(true,"添加脏字列表成功");
		try {
			List<String> dirtyWords=Arrays.asList("脏字"+TestDataManager.getRandomNum(1));
			adddirtywordsBean.setDirtyWords(dirtyWords);
			adddirtywordsCall.setData(adddirtywordsBean);
			adddirtywordsCall.callService();
			Logger.verifyEquals("200", adddirtywordsCall.getString("code"), "验证code");
			for (String dirtyWord : dirtyWords) {
				Logger.verifyIsContains(dirtyWord, LiveRoomCallService.QueryDirtyWords().toString(), "验证dirtyWord");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_AddDirtyWords_002() {
		Logger.start(true,"不输入dirtyWords失败");
		try {
			adddirtywordsCall.setData(adddirtywordsBean);
			adddirtywordsCall.callService();			
			Logger.verifyEquals("100", adddirtywordsCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}